package com.todo.todolist.Service.ServiceImpl;

import com.todo.todolist.Entity.TodoList;
import com.todo.todolist.Repository.TodoListRepository;
import com.todo.todolist.Service.TodoListService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;

@Service
public class TodoListServiceImpl implements TodoListService {
    @Resource
    TodoListRepository todoListRepository;

    @Override
    public TodoList add(TodoList todoList) {
        todoList.setContent("");
        todoList.setIs_done(0);
        todoList.setJ_session("B21A27C1C0DD6C8B2A29F90FC25D426A");
        todoList.setCreate_time(LocalDateTime.now());
        return todoListRepository.save(todoList);
    }

    @Override
    public int delete(String id) {
        todoListRepository.deleteTodoListById(id);
        return 0;
    }
}
